﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Chinaer.UI.MVC.Controllers
{
    public class AreaAddressController : Controller
    {
        //
        // GET: /AreaAddress/

        public ActionResult Index()
        {
            return View();
        }
        public ContentResult GetAreaByCityID(string id)
        {
            Chinaer.WCF.Services.ChinaerService chinaerService = new WCF.Services.ChinaerService();
            var result = chinaerService.GetAreasByCityID(id);
            return new ContentResult()
            {
                Content = Helper.JsonHelper.GetJson(result, result.Count)
            };
        }

        public ContentResult SaveArea(DTO.AreaDTO areaDTO)
        {
            Chinaer.WCF.Services.ChinaerService chinaerService = new WCF.Services.ChinaerService();
            var result = chinaerService.AddArea(areaDTO);
            return new ContentResult()
            {
                Content = Helper.JsonHelper.CreateJson(result)
            };
        }

        public ContentResult UpdateArea(DTO.AreaDTO areaDTO)
        {
            Chinaer.WCF.Services.ChinaerService chinaerService = new WCF.Services.ChinaerService();
            var result = chinaerService.UpdateArea(areaDTO);
            return new ContentResult()
            {
                Content = Helper.JsonHelper.CreateJson(result)
            };
        }


        public ContentResult DeleteArea(string id)
        {
            Chinaer.WCF.Services.ChinaerService chinaerService = new WCF.Services.ChinaerService();
            var result = chinaerService.DeleteAddressByAddressID(id, "");
            return new ContentResult()
            {
                Content = Helper.JsonHelper.CreateJson(result)
            };
        }
    }
}
